'''
Created on 24 avr. 2014

@author: js - be-cloud.be
@license: GPL
'''

import datetime

from protorpc import remote
from google.appengine.ext import endpoints
from google.appengine.ext import ndb

from endpoints_proto_datastore.ndb import EndpointsModel

package = 'Tournament'

class NamedModel(EndpointsModel):

    """Creation Time"""

    created = ndb.DateTimeProperty(auto_now_add=True)
    
    """Name"""
    name = ndb.StringProperty()

class Tournament(NamedModel):
   
    """Trounament Date"""
    date = ndb.DateProperty()
    
class Team(NamedModel):
    
    leader = ndb.StringProperty()
    leader_email = ndb.StringProperty()
    leader_phone = ndb.StringProperty()
    
    members = ndb.StringProperty(repeated = True)
    
    
    
@endpoints.api(name='tournament', version='v1', description='be-Cloud Tournament API')
class TournamentApi(remote.Service):
    
    @Tournament.method(path='tournament', http_method='POST', name='tournament.insert')
    def TournamentInsert(self, tournament):
        tournament.put()
        return tournament
    @Tournament.query_method(path='tournament', name='tournament.list')
    def TournamentlList(self, query):
        return query
     
application = endpoints.api_server([TournamentApi], restricted=False)